home *** CD-ROM | disk | FTP | other *** search
/ AppleScript - The Beta Release / AppleScript - The Beta Release.iso / Developer Scripts / Excel 4.0 AS Examples / Demos / Quarterly Sales / Quarterly Summary Text < prev    next >
Text File  |  1992-11-25  |  2KB  |  55 lines

  1. tell application "Microsoft Excel 4.0"
  2.     make document
  3.     set Range "R2C1:R6C1" to {"Cars", "Planes", "Trucks", "Buses", "Totals"}
  4.     set bold of Range "R6C1:R6C4" to true
  5.     set Range "R2C2:R5C4" to 0
  6.     set cell 2 of row 6 to "=sum(R2C2:R5C2)"
  7.     set cell 3 of row 6 to "=sum(R2C3:R5C3)"
  8.     set cell 4 of row 6 to "=sum(R2C4:R5C4)"
  9. end tell
  10. copy 0 to iregion
  11. repeat with region in {"North", "South", "West"}
  12.     copy iregion + 1 to iregion
  13.     tell application "Microsoft Excel 4.0"
  14.         set formula of cell iregion + 1 of first row to region
  15.     end tell
  16.     tell application "Quill"
  17.         copy region to regionName
  18.         if not (exists window named regionName) then
  19.             tell current application
  20.                 choose file with prompt "Where is the sales memo for the " & regionName & " region?"
  21.             end tell
  22.             open result
  23.         end if
  24.         copy (number of paragraphs in window named regionName) to clines
  25.     end tell
  26.     repeat with iline from 1 to clines
  27.         tell application "Quill"
  28.             copy paragraph iline of window regionName to theline
  29.             copy 0 to r
  30.             if theline contains "Cars" then
  31.                 copy 2 to r
  32.             else if theline contains "Planes" then
  33.                 copy 3 to r
  34.             else if theline contains "Trucks" then
  35.                 copy 4 to r
  36.             else if theline contains "Buses" then
  37.                 copy 5 to r
  38.             end if
  39.             if r > 0 then
  40.                 copy word 2 of paragraph iline of window regionName to theword
  41.                 tell application "Microsoft Excel 4.0"
  42.                     set cell iregion + 1 of row r of first document to theword
  43.                 end tell
  44.             end if
  45.         end tell
  46.     end repeat
  47. end repeat
  48. tell application "Microsoft Excel 4.0"
  49.     copy "R1C1:R5C4" to selection
  50.     make Chart
  51.     set bounds of first window to {10, 100, 440, 360}
  52.     set type of first Chart to three D Bar
  53.     set title of first Chart to "Sales"
  54.     set has legend of first Chart to true
  55. end tell